package git.soulbgm.config;

import git.soulbgm.utils.SpringBeanUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 加解密配置类
 *
 * @author SoulBGM
 * @date 2023-10-08
 */
@Configuration
@ConfigurationProperties(prefix = "api", ignoreUnknownFields = false)
public class KeyConfig {

    public static final String HEADER_CK = "ck";

    /**
     * 加密
     */
    private boolean encrypt = true;

    /**
     * 解密
     */
    private boolean decrypt = true;

    /**
     * 偏移量
     */
    private String iv = "37fa77f6a3b0462d";

    /**
     * 唯一密钥
     */
    private String uniqueKey = "385f33cb91484b04a177828829081ab7";

    /**
     * 配置
     */
    private static KeyConfig config;

    /**
     * 获取配置
     *
     * @return {@link KeyConfig}
     */
    public static KeyConfig getConfig() {
        if (config == null) {
            config = new KeyConfig();//SpringBeanUtil.getBean(KeyConfig.class);
        }
        return config;
    }

    public boolean isEncrypt() {
        return encrypt;
    }

    public void setEncrypt(boolean encrypt) {
        this.encrypt = encrypt;
    }

    public boolean isDecrypt() {
        return decrypt;
    }

    public void setDecrypt(boolean decrypt) {
        this.decrypt = decrypt;
    }

    public String getIv() {
        return iv;
    }

    public void setIv(String iv) {
        this.iv = iv;
    }

    public String getUniqueKey() {
        return uniqueKey;
    }

    public void setUniqueKey(String uniqueKey) {
        this.uniqueKey = uniqueKey;
    }
}
